/**
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 */

export class FileSet {
  private _group = new Map<string, FsOptions>();

  addEntry(path: string, options?: FsOptions) {
    this._group.set(path, options ? options : {});
    return this;
  }

  deleteEntry(path: string) {
    if (this._group.has(path)) {
      this._group.delete(path);
    }
    return this;
  }

  addEntries(entries: string[], options?: FsOptions) {
    entries.forEach((entry) => {
      const optionsTmp = { ...options };
      this._group.set(entry, optionsTmp ? optionsTmp : {});
    });
    return this;
  }

  collect(): Map<string, FsOptions> {
    return this._group;
  }
}

/**
 * 任务输入输出路径选项
 *
 * @since 2022/8/31
 */
export interface FsOptions {
  isDirectory?: boolean;

  /**
   * 正则表达式字符串
   */
  test?: RegExp;

  /**
   * 文件夹深度
   */
  depth?: number;

  /**
   * 该文件对应的FileSnapShot快照的HashValue
   */
  fileSnapShotHashValue?: string;
}
